package com.wms.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wms.bean.PageBean;
import com.wms.code.CodeFactory;
import com.wms.dto.BtransfersentDTO;
import com.wms.dto.PageVo;
import com.wms.entity.Btransfersent;
import com.wms.mapper.BtransfersentMapper;
import com.wms.service.BtransfersentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BtransfersentServiecImpl implements BtransfersentService {

    @Autowired
    BtransfersentMapper btransfersentMapper;

    //配送区的编码
    String prefix = "ZK";
    @Override
    public PageBean<List<Btransfersent>> selectBtran(BtransfersentDTO btransfersentDTO) {
        PageHelper.startPage(btransfersentDTO.getPage(),btransfersentDTO.getPageSize());
        List<Btransfersent> list =  btransfersentMapper.selectBtran(btransfersentDTO);
        PageInfo<Btransfersent> pageInfo = new PageInfo<>(list);
        return new PageBean<List<Btransfersent>>(btransfersentDTO.getPage(),btransfersentDTO.getPageSize(),pageInfo.getTotal(),pageInfo.getList());
    }


    @Override
    public int insert(Btransfersent btransfersent) {
        String MaxCode = btransfersentMapper.selectMaxCode();
        btransfersent.setUnit(CodeFactory.createArrivalCode(MaxCode, prefix));
        return btransfersentMapper.insert(btransfersent);
    }
}
